﻿using MeetAI.Service.IService;
using MeetAI.Utility;
using Nancy;

namespace MeetAI.API.Modules
{
    public class adsTypeModule : NancyModule
    {
        private readonly IDy_Ads_Service IDy_Ads_Service;
        public adsTypeModule(IDy_Ads_Service IDy_Ads_Service) : base("/v1/ads")
        {
            this.IDy_Ads_Service = IDy_Ads_Service;
            //获取banner
            Get["/{taid}", true] = async (param, token) =>
            {
                Result res = new Result();
                int? taid = param.taid;
                if (!taid.HasValue)
                {
                    res.code = ResultType.fail;
                    res.message = "参数错误";
                    return Response.AsJson(res);
                }
                res.data = await IDy_Ads_Service.getAds(s => s.taid.Equals(taid) && s.isshow.Equals(1));
                return Response.AsJson(res);
            };
        }
    }
}